#{extends 'main.html' /}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="pt-BR">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>

	<h2>Locais</h2>
	<hr />
	<div style="min-height: 200px; height: auto;">
		<form action="adicionarLocal" method="POST"
			style="width: 35%; display: inline-block; float: left;">
			<fieldset>
				#{field 'descricao'}
				<div class="control-group ${errors.forKey(field.name)?'error':''}">
					<label for="${field.name}" class="control-label">Descricao</label>
					<div class="controls">
						<input type="text" name="${field.name}" value="${field.value}"
							class="span5 input-large"> <span class="help-inline">${errors.forKey(field.name)}</span>
					</div>
					<span class="help-inline">${errors.forKey(field.name)}</span>
				</div>
				#{/field}
			</fieldset>
			<button class="btn btn-primary" type="submit">Adicionar
				Local</button>

		</form>
		<div style="width: 63%; float: left; display: inline-block;">
			<table id="locais"
				class="table tablesorter table-bordered table-striped">
				<thead>
					<tr>
						<th>Id</th>
						<th>Descricao</th>
						<th>Acoes</th>
					</tr>
				</thead>
				<tbody>
					#{if vertices.size() > 0} #{list items:vertices, as:'v'}
					<tr>
						<td style="width: 10%;">${v.id}</td>
						<td style="width: 30%;">${v.descricao}</td>
						<td><a href="@{Carteiros.removerLocal(v.id)}">Remover</a></td>
					</tr>
					#{/list} #{/if} #{else}
					<tr>
						<td colspan="3">Nao ha locais cadastrados.</td>
					</tr>
					#{/else}
				</tbody>
			</table>
		</div>
	</div>
	<br />
	<br />
	<h2>Caminhos</h2>
	<hr />

	<div style="min-height: 350px;">
		<form action="adicionarCaminho" method="POST"
			style="width: 35%; display: inline-block; float: left;">
			<fieldset>
				#{field 'descricao'}
				<div class="control-group ${errors.forKey(field.name)?'error':''}">
					<label for="${field.name}" class="control-label">Descricao</label>
					<div class="controls">
						<input type="text" name="${field.name}" value="${field.value}"
							class="span5 input-large"> <span class="help-inline">${errors.forKey(field.name)}</span>
					</div>
					<span class="help-inline">${errors.forKey(field.name)}</span>
				</div>
				#{/field} #{field 'idVOrigem'} <label for="${field.name}"
					class="control-label">Local Inicial</label>
				<div class="controls">
					<Select name="${field.name}" id="idVOrigem" value="${field.value}"
						class="input-large">
						<option value="-1" selected="selected">Selecione um
							local...</option> #{list vertices, as:'v'}
						<option value="${v.id}">${v.descricao}</option> #{/list}
					</Select> <span class="help-inline">${errors.forKey(field.name)}</span>
				</div>
				#{/field} #{field 'idVDestino'} <label for="${field.name}"
					class="control-label">Local Final</label>
				<div class="controls">
					<Select name="${field.name}" id="idVDestino" value="${field.value}"
						class="input-large">
						<option value="-1" selected="selected">Selecione um
							local...</option> #{list vertices, as:'v'}
						<option value="${v.id}">${v.descricao}</option> #{/list}
					</Select> <span class="help-inline">${errors.forKey(field.name)}</span>
				</div>
				#{/field}
			</fieldset>
			#{field 'distancia'}
			<div class="control-group ${errors.forKey(field.name)?'error':''}">
				<label for="${field.name}" class="control-label">Distancia
					entre inicio e fim (km)</label>
				<div class="controls">
					<input type="text" name="${field.name}" value="${field.value}"
						class="span5 input-large"> <span class="help-inline">${errors.forKey(field.name)}</span>
				</div>
				<span class="help-inline">${errors.forKey(field.name)}</span>
			</div>
			#{/field}
			<button class="btn btn-primary" type="submit">Adicionar
				Caminho</button>
		</form>
		<div style="width: 63%; display: inline-block; float: left;">
			<table id="caminhos"
				class="table tablesorter table-bordered table-striped">

				<thead>
					<tr>
						<th>Id</th>
						<th>Descricao</th>
						<th>Local Origem</th>
						<th>Local Destino</th>
						<th>Distancia</th>
						<th>Acoes</th>
					</tr>
				</thead>
				<tbody>
					#{if arestas.size() > 0} #{list items:arestas, as:'a'}
					<tr>
						<td>${a.id}</td>
						<td>${a.descricao}</td>
						<td>${a.verticeOrigem.descricao}</td>
						<td>${a.verticeDestino.descricao}</td>
						<td>${a.ganho}</td>
						<td><a href="@{Carteiros.removerCaminho(a.id)}">Remover</a></td>
					</tr>
					#{/list} #{/if} #{else}
					<tr>
						<td colspan="6">Nao ha caminhos cadastrados.</td>
					</tr>
					#{/else}
				</tbody>
			</table>

		</div>
	</div>
	<div style="display: block;">
		<a href="/carteiros/acharMelhorCaminho">Achar melhor caminho</a>
	</div>
</body>
</html>